package com.disdr.utils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class FileReaderUtil {

    /**
     * 读取项目中 resources 目录下的 private_key2.pem 文件内容并打印
     */
    public static void readAndPrintPrivateKey() {
        String fileName = "private_key2.pem";
        try (InputStream inputStream = FileReaderUtil.class.getClassLoader().getResourceAsStream(fileName);
             BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
            if (inputStream == null) {
                System.out.println("未找到 " + fileName + " 文件");
                return;
            }
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
        } catch (IOException e) {
            System.err.println("读取文件 " + fileName + " 时出错: " + e.getMessage());
        }
    }

    public static void main(String[] args) {
        readAndPrintPrivateKey();
    }
}